function Node(value){
    this.value = value;
    this.left = null;
    this.right = null;
}

var a = new Node("a");
var b = new Node("b");
var c = new Node("c");
var d = new Node("d");
var e = new Node("e");
var f = new Node("f");
a.left = b;
a.right = c;
b.left = d;
b.right = e;
d.left = f;

function dfc(root, targetValue) {
    if(!root) return false;
    if(root.value == targetValue) return true;
    return dfc(root.left,targetValue) || dfc(root.right,targetValue);
}

function bfc(arr,targetValue){
    var newArr = [];
    if(arr.length == 0) return false;
    for(var i = 0;i < arr.length;i ++){
        if(arr[i].value == targetValue) return true;
        else {
            if(arr[i].left != null){
                newArr.push(arr[i].left);
            }
            if(arr[i].right != null){
                newArr.push(arr[i].right);
            }
        }
    }
    return bfc(newArr,targetValue);
}

// console.log(dfc(a,'n'));

// console.log(bfc([a],'e'));
module.exports = a;